查找bigkeys
redis-cli --i 0.1 --bigkeys //100ms执行一次
redis-cli -a yaoran -r 3 -i 0.01 --bigkeys
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type. You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).
[00.00%] Biggest string found so far 'aaaa' with 3 bytes
[00.00%] Biggest string found so far 'ab:cdd:dfew:dfew:dfwefe:ewfew:ewww:ewfew:ewfew:ewfwef:efwfew:fewfe:fewfe:ss' with 31 bytes
-------- summary -------
Sampled 5 keys in the keyspace!
Total key length in bytes is 89 (avg len 17.80)
Biggest string found 'ab:cdd:dfew:dfew:dfwefe:ewfew:ewww:ewfew:ewfew:ewfwef:efwfew:fewfe:fewfe:ss' has 31 bytes
5 strings with 42 bytes (100.00% of keys, avg size 8.40)
0 lists with 0 items (00.00% of keys, avg size 0.00)
0 sets with 0 members (00.00% of keys, avg size 0.00)
0 hashs with 0 fields (00.00% of keys, avg size 0.00)
0 zsets with 0 members (00.00% of keys, avg size 0.00)
0 streams with 0 entries (00.00% of keys, avg size 0.00)
查看value的具体信息
127.0.0.1:6379> debug object jsonbig
Value at:0x7fe2d4d087c0 refcount:1 encoding:raw serializedlength:151 lru:9712799 lru_seconds_idle:10
serializedlength代表key 对应的value序列化的字节数,如果是字符串,也可以用strlen来查看
127.0.0.1:6379> strlen jsonbig
(integer) 1664
查看占用内存
redis4.0之后可以用memory usage 查看key的占用内存
127.0.0.1:6379> memory usage jsonbig
(integer) 1719
数据量大的话可以用scan + memory usage(pipline)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。